document.getElementById("sub").onclick = function () {
    // alert("111")
    let call = new Promise(
        (resolve, reject) => {
            const xhr = new XMLHttpRequest()
            // xhr.open("GET", "http://localhost:9000/user/login?account=q&password=1")
            xhr.open("GET", "http://localhost:9000/user/r?id=1")
            //传递多个参数要用数组或者对象
            xhr.onload = () => {
                //这里创建对象
                // let aaa = {
                //     restext:xhr.responseText,
                //     bbb:"你好"
                // }
                //后端返回的json格式数据
                resolve(xhr.response)
            }
            xhr.onerror = () => reject(xhr)
            xhr.send()
        }
    )

    call
        .then((e) => {
            // window.location = '../html/index.html'
            //转成json格式
            console.log(e)
            let data = JSON.parse(e)
            document.getElementById("a").innerHTML = data.msg +"你好"
            console.log(data.data)
            console.log(data.data.age)

        })
        .catch((e) => {
            alert("请求失败")
        })

}